package logic

import (
	"context"
	"shenzhou/B/srv/car"
	"shenzhou/B/srv/internal/svc"
	"shenzhou/B/srv/models/mysql"

	"github.com/zeromicro/go-zero/core/logx"
)

type UsersUpdateLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUsersUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UsersUpdateLogic {
	return &UsersUpdateLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *UsersUpdateLogic) UsersUpdate(in *car.UsersUpdateRequest) (*car.UsersUpdateResponse, error) {
	// todo: add your logic here and delete this line

	u := mysql.User{
		Status: in.Status,
	}
	err := u.Update(in.UserId)
	if err != nil {
		logx.Error("冻结账号失败")
		return nil, err
	}
	return &car.UsersUpdateResponse{UserId: int64(u.ID)}, nil
}
